//
//  LXTableBarController.m
//  duoduo
//
//  Created by wanghao on 16/10/11.
//  Copyright © 2016年 LX. All rights reserved.
//

#import "LXTableBarController.h"
#import "LXNavigationController.h"
#import "Home_ViewController.h"
#import "Driving_ViewController.h"
#import "Mine_ViewController.h"
#import "LeaderView.h"

@interface LXTableBarController ()<UITabBarControllerDelegate,UINavigationControllerDelegate>

@end

@implementation LXTableBarController

- (void)viewDidLoad {
    [super viewDidLoad];


    NSArray * tabBarTitleArray = @[@"拼车",@"自驾",@"我的"];
    NSArray * tabBarImagesArray = @[@"pinche1",@"zijia1",@"wode1"];
    NSArray * tabBarOrangeImagesArray = @[@"pinche",@"zijia",@"wode"];


    Home_ViewController * home = [[Home_ViewController alloc]init];

    LXNavigationController * homeNav = [[LXNavigationController alloc]initWithRootViewController:home];
    Driving_ViewController *driving = [[Driving_ViewController alloc]init];
     LXNavigationController * drivingNav = [[LXNavigationController alloc]initWithRootViewController:driving];

    Mine_ViewController * mine = [[Mine_ViewController alloc]init];
     LXNavigationController * mineNav = [[LXNavigationController alloc]initWithRootViewController:mine];

    self.viewControllers = @[homeNav,drivingNav,mineNav];
    UITabBarItem * homeButton = self.tabBar.items[0];
    UITabBarItem * drivingButton = self.tabBar.items[1];
    UITabBarItem * mineButton = self.tabBar.items[2];

    //tabBar标题名称
    homeButton.title = tabBarTitleArray[0];
    drivingButton.title = tabBarTitleArray[1];
    mineButton.title = tabBarTitleArray[2];

    //tabBar标题图片
    homeButton.image = [[UIImage imageNamed:tabBarImagesArray[0]]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    drivingButton.image = [[UIImage imageNamed:tabBarImagesArray[1]]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    mineButton.image = [[UIImage imageNamed:tabBarImagesArray[2]]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    //tabBar标题选择后的图片
    homeButton.selectedImage = [[UIImage imageNamed:tabBarOrangeImagesArray[0]]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    drivingButton.selectedImage = [[UIImage imageNamed:tabBarOrangeImagesArray[1]]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    mineButton.selectedImage = [[UIImage imageNamed:tabBarOrangeImagesArray[2]]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];


    //背景颜色
    [[UITabBar appearance] setBarTintColor:[UIColor whiteColor]];

    //正常文字颜色
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor grayColor],NSFontAttributeName:[UIFont systemFontOfSize:12]} forState:UIControlStateNormal];
    //选中后文字颜色
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor grayColor],NSFontAttributeName:[UIFont systemFontOfSize:12]} forState:UIControlStateSelected];

    


}

- (void)setupChildVc:(UIViewController *)vc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage
{
//    vc.navigationItem.title = title;
//    vc.tabBarItem.title = title;
//    vc.tabBarItem.image = [UIImage imageNamed:image];
//    vc.tabBarItem.selectedImage = [UIImage imageNamed:selectedImage];

    LXNavigationController  *nav = [[LXNavigationController alloc] initWithRootViewController:vc];

    [self addChildViewController:nav];
}


@end
